<?php
require_once "../../PCO.php";
require_once "../../global-themis/Classes/client.class";
require_once "../../global-themis/functions/functions.php";
$nom_cli="";
$sir_cli="";
$res_cli="";
$num_cli="";
if($_GET[VAR_GET_CLI]!=""){
	$num_cli=$_GET[VAR_GET_CLI]; // recuperer le numero du client en GET.
	$client = new Client();
	$client->setNum($num_cli);
	$client->getAllByNum($num_cli); //recuperer les infos du client.
	$nom_cli=$client->getNom(); // nom du client
	$sir_cli=$client->getSiren(); // SIREN du client
	$res_cli=$client->getResp();  // Responsable du client.
	
}
else {
	echo "Error numero client ..";
}


?>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="keywords" content="">
	<meta name="description" content="">
	<title>Client <?php echo $num_cli; ?></title>
	<link rel="stylesheet" type="text/css" href="../../global-themis/css/easyui.css">
	<link rel="stylesheet" type="text/css" href="../../global-themis/css/themisstyle.css">
	<link rel="stylesheet" type="text/css" href="../../global-themis/css/icon.css">
	<script type="text/javascript" src="../../global-themis/js/jquery.js"></script>
	<script type="text/javascript" src="../../global-themis/js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../global-themis/js/cookie.jquery.js"></script>	
    <script type="text/javascript" src="../../global-themis/js/jquery.editinplace.js"></script>
	<script>
	$(document).ready(function(){
		$(".panel-body").css("background","#AFCBF3");
		// $("a.tabs-inner:first").closest('li').css("background", "#D4D8D7"); 
		//Gwen : pas de positionnement absolute en px stp ! Préférer des solutions comme expliqué : http://openweb.eu.org/articles/initiation_float
		$(".tabs").append("<span style='margin-left:5%'><select id='cli' ><option value='1'>Onglet 1</option><option value='2'>Onglet 2</option><option value='3'>Onglet 3</option></select>&nbsp;<input size='15' type='text' id='add' />&nbsp;<input type='button' value='MAJ titre' id='ajout' /></span>");
		var id="tabs";
		var cook="";
		$('.tabs-title').each(function(i){
		$(this).attr("id", i+1);
		});
		if($.cookie(id)==null){
			$("#1").html("Onglet 1");
			$("#2").html("Onglet 2");
			$("#3").html("Onglet 3");
			cook=$("#1").text()+"|"+$("#2").text()+"|"+$("#3").text();
			$.cookie(id,cook);
		}
		else {
			var col=$.cookie(id).split("|");
			$("#1").html(col[0]);
			$("#2").html(col[1]);
			$("#3").html(col[2]);
		}

		var width=document.body.clientWidth;
		$(window).bind('resize', function() {
			 if (document.body.clientWidth!=width)
			   {window.location.href = window.location.href;
			    width=document.body.clientWidth;
  			   }		 
			});	
		});
	</script>
	<script>
	$(document).ready(function(){
		$("#ajout").click(function(){
			var id="tabs";
			var cook="";
			var onglet=$("#cli").val();
			var texte=$('#add').val();
			if(texte !=""){
				if(onglet==1){
					$("#"+onglet).text(texte);
					cook=$("#"+onglet).text()+"|"+$("#2").text()+"|"+$("#3").text();
					$.cookie(id, cook);
				}				
				else if(onglet==2){
					$("#"+onglet).text(texte);
					cook=$("#1").text()+"|"+$("#"+onglet).text()+"|"+$("#3").text();
					$.cookie(id, cook);
				
				}				
				
				else if(onglet==3){
					$("#"+onglet).text(texte);
					cook=$("#1").text()+"|"+$("#2").text()+"|"+$("#"+onglet).text();
					$.cookie(id, cook);
				}
				else {
					alert("Erreur : vous avez tapé un titre qui existe dejà.")
				}
			}
			else {
				alert("Remplissez le champ texte svp");
			}
		})
	});
	</script>
	<script type="text/javascript">	
		$(document).ready(function(){
			$("#note").keyup(function(){
				$("#sauv").css("display", "inline");
				$("#annul").css("display", "inline");
			});
		});
    </script>	
	<script type="text/javascript">	
		$(document).ready(function(){
			var valu="<?php echo getNote($num_cli); ?>";
			if($.trim(valu)=="")
				valu="Inserer une note sur le client: <?php echo $num_cli; ?>";
			var reg=new RegExp("(,)", "g");
			 valu=valu.replace(reg, "\n");
			 $("#note").val(valu);
		});
    </script>		
	<script type="text/javascript">	
		$(document).ready(function(){
			$("#sauv").click(function(){
				var textar=$.trim($("#note").val());
				textar = textar.replace(/[@#$%\^&*=_+"'\/<>\\\|{}\[\]]/g,"");
				textar = textar.replace(/[\t ]+/g,' ');
				textar = textar.replace(/\n{1,}/g,'\n\n');
				textar = textar.split(/\n/);
				var dataString = "id="+<?php echo $num_cli;?>+"&value="+textar;
				// alert(dataString);
				$.ajax	({
					type: "POST",
					url: "../post-it/note.php",
					data: dataString,
					cache: false,
					success: function(html){
						if(textar=="")
							$("#note").val("Inserer une note sur le client: <?php echo $num_cli; ?>");
						$("#sauv").css("display", "none");
						$("#annul").css("display", "none");
					},
					error: function(xhr, status, errorThrown) {
							alert(xhr+ ' : error ajax - contactez DESI : status '+ status + ' && ' + errorThrown);
					}
				});
			})
			$("#annul").click(function(){
				var valu="<?php echo getNote($num_cli); ?>";
				if($.trim(valu)=="")
					valu="Inserer une note sur le client: <?php echo $num_cli; ?>";
				var reg=new RegExp("(,)", "g");
				valu=valu.replace(reg, "\n");
				$("#note").val(valu);
				$("#sauv").css("display", "none");
				$("#annul").css("display", "none");
			});
		});
    </script>
</head>
<body>
	<div style='margin: 3px 3px 3px 3px;display:block;overflow:visible;'>
		<table  class='t_head_mini'>
			<tr>
				<td rowspan='2'>
					<img src="../../global-themis/images/logo.gif"  class='logo'>
				</td>
				<th>
					Client
				</th>
				<th>	
					SIREN
				</th>
				<th>	
					Responsable
				<th>
			</tr>
			<?php
			echo "<tr><td><span id='num_cli'>".$num_cli."</span>&nbsp;";
			echo $nom_cli;
			echo "<td>".$sir_cli;
			echo "<td>".$res_cli."</td></tr>";
			?>
			</table>
		<FIELDSET style='width:45%;float:right;overflow:visible;'>
			<LEGEND align=top> Post-it:</LEGEND> 
			<textarea cols="68" rows='4'  id="note" style="background-color:#eedd82;"  >
			</textarea><br>
			<input type='button' value='Sauvegarder' id='sauv' style="display: none;"/>
			<input type='button' value='Annuler' id='annul' style="display: none;"/>
		</FIELDSET>
	</div><br>
	<div id="tt" class="easyui-tabs" width="95%" height="480%" style='background:#AFCBF3;margin: 117px 0px 0px 0px;'>
		<div title="" id="c1" height="100%">
			<iframe scrolling="no" frameborder="0"   src="./C1/igoogle_client.php?numCli=<?php echo $num_cli; ?>" style="width:100%;height:450%;"></iframe>
		</div>
		
		<div title="" id="c2">
			<iframe scrolling="auto" frameborder="0"   src="./C2/igoogle_client.php?numCli=<?php echo $num_cli; ?>" style="width:100%;height:450%;"></iframe>
		</div>
		
		<div title="" id="c3">
			<iframe scrolling="auto" frameborder="0"  src="./C3/igoogle_client.php?numCli=<?php echo $num_cli; ?>" style="width:100%;height:450%;"></iframe>
		</div>
	</div>
</body>
</html>